package com.example.demo1.web;

import com.example.demo1.service.CourseService;
import com.example.demo1.service.Impl.CourseServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(name = "course",urlPatterns = "/course")
public class Course extends HttpServlet {
        CourseService courseService = new CourseServiceImpl();

        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            String course = courseService.getCourse();
//        字符编码集
            resp.setCharacterEncoding("utf-8");
//        字符类型
            resp.setContentType("text/html");
            resp.getWriter().println(course);
        }

        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        }
}
